package com.zjp.controller;

import com.zjp.pojo.Area;
import com.zjp.pojo.City;
import com.zjp.pojo.Province;
import com.zjp.service.AreaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 根据areaSelect.文件联动查询  1.查询所有省份，2.根据省份查看所有城市。3.根据市查看所有县/区。
 */
@RestController //负责地区模块的controller
@Slf4j
public class AreaController {
    @Autowired
    private AreaService areaService;

    //查询所有省份
    @RequestMapping("/findAllProvince")
    public List<Province> findAllProvince(){
        List<Province> provinceList=areaService.findAllProvince();
        return provinceList;
    }
    //根据省份查看所有城市
    @RequestMapping("/findCityByProvince")
    public List<City> findCityByProvince(String provinceid){
        List<City> cityList=areaService.findCityByProvince(provinceid);

        return cityList;
    }

    //根据市查看所有县/区
    @RequestMapping("/findAreaByCity")
    public List<Area> findAreaByCity(String cityid){
        List<Area> areaList=areaService.findAreaByCity(cityid);
        return areaList;
    }
}